/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/** 
 * @author Igor A. Pyankov 
 */ 

package org.apache.harmony.x.print.ipp;

/**
 * This class represents Job and Printer Set Operations 
 * described in RFC 3380 (http://ietf.org/rfc/rfc3380.txt?number=3380)
 */

public class IppDefs {
    public static final Object[] JOBTEMPLATEATTRIBUTES = { "job-priority",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "job-priority-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "job-priority-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },

            "job-hold-until",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "job-hold-until-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "job-hold-until-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },

            "job-sheets",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "job-sheets-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "job-sheets-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },

            "multiple-document-handling",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "multiple-document-handling-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "multiple-document-handling-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },

            "copies",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "copies-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "copies-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_RANGEOFINTEGER },

            "finishings",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },
            "finishings-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },
            "finishings-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },

            "page-ranges",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_RANGEOFINTEGER },
            "page-ranges-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_BOOLEAN },

            "sides",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "sides-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "sides-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },

            "number-up",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "number-up-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "number-up-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },

            "orientation-requested",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },
            "orientation-requested-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },
            "orientation-requested-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },

            "media",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "media-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "media-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "media-ready",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },

            "printer-resolution",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_RESOLUTION },
            "printer-resolution-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_RESOLUTION },
            "printer-resolution-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_RESOLUTION },

            "print-quality",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },
            "print-quality-default",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },
            "print-quality-supported",
            new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
                    IppAttribute.TAG_ENUM } };

    public static final Object[] JOBDESCRIPTIONATTRIBUTES = { "job-uri",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_URI },
            "job-id",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "job-printer-uri",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_URI },
            "job-more-info",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_URI },
//            "job-name",
//            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
//                    IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
            "job-originating-user-name",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
            "job-state",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },
            "job-state-reasons",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "job-state-message",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
            "job-detailed-status-messages",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
            "job-document-access-errors",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
            "number-of-documents",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "output-device-assigned",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
            "time-at-creation",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "time-at-processing",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "time-at-completed",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "job-printer-up-time",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "date-time-at-creation",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_DATETIME },
            "date-time-at-processing",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_DATETIME },
            "date-time-at-completed",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_DATETIME },
            "number-of-intervening-jobs",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "job-message-from-operator",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
            "job-k-octets",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "job-impressions",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "job-media-sheets",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "job-k-octets-processed",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "job-impressions-completed",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "job-media-sheets-completed",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "attributes-charset",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_CHARSET },
            "attributes-natural-language",
            new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
                    IppAttribute.TAG_NATURAL_LANGUAGE } };

    public static final Object[] PRINTERDESCRIPTIONATTRIBUTES = { "printer-uri-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_URI },
            "uri-security-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "uri-authentication-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "printer-name",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
            "printer-location",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
            "printer-info",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
            "printer-more-info",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_URI },
            "printer-driver-installer",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_URI },
            "printer-make-and-model",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
            "printer-more-info-manufacturer",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_URI },
            "printer-state",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },
            "printer-state-reasons",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "printer-state-message",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
            "ipp-versions-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "operations-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_ENUM },
            "multiple-document-jobs-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_BOOLEAN },
            "charset-configured",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_CHARSET },
            "charset-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_CHARSET },
            "natural-language-configured",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_NATURAL_LANGUAGE },
            "generated-natural-language-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_NATURAL_LANGUAGE },
            "document-format-default",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_MIMEMEDIATYPE },
            "document-format-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_MIMEMEDIATYPE },
            "printer-is-accepting-jobs",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_BOOLEAN },
            "queued-job-count",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "printer-message-from-operator",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
            "color-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_BOOLEAN },
            "reference-uri-schemes-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_URISCHEME },
            "pdl-override-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "printer-up-time",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "printer-current-time",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_DATETIME },
            "multiple-operation-time-out",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "compression-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_KEYWORD },
            "job-k-octets-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_RANGEOFINTEGER },
            "job-impressions-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_RANGEOFINTEGER },
            "job-media-sheets-supported",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_RANGEOFINTEGER },
            "pages-per-minute",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER },
            "pages-per-minute-color",
            new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
                    IppAttribute.TAG_INTEGER } };

    public static final Object[] PRINTEROPERATIONATTRIBUTES = { "requesting-user-name",
            new byte[] { IppAttributeGroup.TAG_OPERATION_ATTRIBUTES,
                    IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
            "job-name",
            new byte[] { IppAttributeGroup.TAG_OPERATION_ATTRIBUTES,
                    IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
            "document-name",
            new byte[] { IppAttributeGroup.TAG_OPERATION_ATTRIBUTES,
                    IppAttribute.TAG_NAMEWITHOUTLANGUAGE } };

    public static final Object[] ATAGS = { JOBTEMPLATEATTRIBUTES,
            JOBDESCRIPTIONATTRIBUTES,
            PRINTERDESCRIPTIONATTRIBUTES,
            PRINTEROPERATIONATTRIBUTES };

    // TODO need to tune for performance
    public static byte getAttributeGtag(String aname) {
        for (int ii = ATAGS.length, i = 0; i < ii; i += 1) {
            Object[] atags = (Object[]) ATAGS[i];
            for (int j = 0, jj = atags.length; j < jj; j+=2) {
                if (aname.equals(atags[j])) {
                    return ((byte[]) atags[j + 1])[0];
                }
            }
        }
        return -1;
    }

    // TODO need to tune for performance
    public static byte getAttributeVtag(String aname) {
        for (int ii = ATAGS.length, i = 0; i < ii; i += 1) {
            Object[] atags = (Object[]) ATAGS[i];
            for (int j = 0, jj = atags.length; j < jj; j+=2) {
                if (aname.equals(atags[j])) {
                    return ((byte[]) atags[j + 1])[1];
                }
            }
        }
        return -1;
    }

}
